package com.test.ssm.controller;

import com.test.ssm.pojo.Flight;
import com.test.ssm.pojo.Ticket;
import com.test.ssm.service.FlightService;
import com.test.ssm.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @author 徒有琴
 */
@RestController
public class FlightController {
    @Autowired
    private FlightService flightService;
    @Autowired
    private TicketService ticketService;

    @RequestMapping("/flights")
    public List<Flight> flights(Date time, String off, String arrive) {
        return flightService.getFlights(time, off, arrive);
    }

    @RequestMapping("/ticket")
    public List<Ticket> ticket(Integer flightId) {
        return ticketService.getTicketByFlightId(flightId);
    }
}
